package com.imelite.qyh.action;

import com.imelite.qyh.model.EliteCRMView_OrgUser;
import com.imelite.qyh.model.EliteCRMView_Yyxx;
import com.imelite.qyh.model.YyxxWithBLOBs;
import com.imelite.qyh.service.EliteCRMView_OrgUserService;
import com.imelite.qyh.service.EliteCRMView_YyxxService;
import com.imelite.qyh.service.YyxxService;
import com.imelite.qyh.util.BaseResponseUtil;
import com.imelite.qyh.util.BaseStringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class EliteView_YyxxAction {

    @Autowired
    private EliteCRMView_YyxxService eliteCRMView_yyxxService;
    @Autowired
    private EliteCRMView_OrgUserService eliteCRMView_orgUserService;
    @Autowired
    private YyxxService yyxxService;


    @RequestMapping("/com/imelite/qyh/EliteView_YyxxAction/yyxxByTelPage")
    public String yyxxByTelPage(HttpServletRequest request, HttpServletResponse response, String iddep) {
        if(BaseStringUtil.isBlank(iddep)){
            return "/Elite/jxcpLogin";
        }
        request.setAttribute("iddep",iddep);


        return "/Elite/yyxx/yyxx_list";
    }

    @RequestMapping("/com/imelite/qyh/EliteView_YyxxAction/ajax_getYyxxByForm")
    public String ajax_getYyxxByForm(HttpServletRequest request, HttpServletResponse response,EliteCRMView_Yyxx yyxx){
        List<EliteCRMView_Yyxx> yyxxList=eliteCRMView_yyxxService.selectByForm(yyxx);
        List<EliteCRMView_OrgUser> sc_cdlist=eliteCRMView_orgUserService.selectBySC_CD(yyxx.getIddep());
        request.setAttribute("iddep",yyxx.getIddep());
        request.setAttribute("stuph",yyxx.getStuph());
        request.setAttribute("sc_cdlist",sc_cdlist);
        request.setAttribute("yyxxList",yyxxList);
        return "/Elite/yyxx/yyxx_list";
        //BaseResponseUtil.responseAjaxJsonModel(response, yyxxList);
    }

    @RequestMapping("/com/imelite/qyh/EliteView_YyxxAction/update_idowner")
    public void update_idowner(HttpServletRequest request, HttpServletResponse response, YyxxWithBLOBs yyxxWithBLOBs){
        yyxxService.updateByPrimaryKeySelective(yyxxWithBLOBs);
    }
}
